#include "StrUtil.h"
#include<Windows.h>


StrUtil::StrUtil()
{
}


StrUtil::~StrUtil()
{
}

wchar_t * StrUtil::towchar_t(const char * szStr)
{
    int nLen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szStr, -1, NULL, 0);
    if (nLen == 0) { return NULL; }
    wchar_t* pResult = new wchar_t[nLen];
    MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szStr, -1, pResult, nLen);
    return pResult;
}

wchar_t * StrUtil::towchar_t(const std::string src)
{
    int nLen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, src.data(), -1, NULL, 0);
    if (nLen == 0) { return NULL; }
    wchar_t* pResult = new wchar_t[nLen];
    MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, src.data(), -1, pResult, nLen);
    return pResult;
}
